package org.nanhill.commons.math;

/**
 * @author alin
 * 
 */
public class Matrix {
	/**
	 * @param in
	 *            the input matrix
	 * @return the rotated matrix, throw IllegalArgumentException if input
	 *         matrix has zero-sized rows or zero-sized columns
	 */
	public static int[][] rotate(int[][] in) {
		int rows = in.length;
		if (0 == rows)
			throw new IllegalArgumentException("row sum error: " + rows);
		int cols = in[0].length;
		if (0 == cols)
			throw new IllegalArgumentException("column sum error: " + cols);
		int[][] out = new int[cols][rows];
		for (int i = 0; i < rows; i++) {
			for (int j = 0; j < cols; j++) {
				out[j][i] = in[i][j];
			}
		}
		return out;
	}
}
